package de.koller.aframe.util.misc;

public class ATimer {
	
	private final long delay;
	private long currentTime = 0;
	private long nextTick;
	
	public ATimer( long delay ) {
		this.delay = delay;
		this.nextTick = delay;
	}
	
	public boolean step( long elapsedTime ) {
		currentTime += elapsedTime;
		
		if( nextTick < currentTime ) {
			nextTick += delay;
			return true;
		}
		
		return false;
	}

	public long timeToNextTick() {
		return nextTick - currentTime;
	}
	
}
